package com.ds.extend.aware.eventPublisher;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

/**
 * 发布类
 * @author qiuxl
 *
 */
@Component
public class ApplicationEventPublisherAwareTest implements ApplicationEventPublisherAware , InitializingBean{
	
	private ApplicationEventPublisher applicationEventPublisher;
	
	@Override
	public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
		this.applicationEventPublisher = applicationEventPublisher;
		
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		//用户注册
		System.out.println("[service]用户[test]注册成功！");
		//消息发布
		applicationEventPublisher.publishEvent(new UserRegisterEvent(this, "test"));	
	}
}
